# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=pixman
pkgver=0.42.2
pkgrel=2
pkgdesc="Low-level pixel manipulation library"
url="https://gitlab.freedesktop.org/pixman"
arch="all"
license="MIT"
makedepends="meson libpng-dev linux-headers"
subpackages="$pkgname-static $pkgname-dev $pkgname-dbg"
source="https://www.x.org/releases/individual/lib/pixman-$pkgver.tar.xz
	scaling-test.patch
	"

case "$CARCH" in
	# broken test (likely due to endianness assumptions)
	s390x) options="!check" ;;
esac

build() {
	case "$CARCH" in
	armhf)
		# target-specific builtin not available
		local lto=false
		;;
	*)
		local lto=true
		;;
	esac
	# We need to increase the stacksize here: https://gitlab.gnome.org/GNOME/librsvg/-/issues/595
	LDFLAGS="$LDFLAGS -Wl,-z,stack-size=2097152" \
	abuild-meson \
		-Db_lto=$lto \
		-Ddefault_library=both \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output -t 10
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
3476e2676e66756b1af61b1e532cd80c985c191fb7956eb01702b419726cce99e79163b7f287f74f66414680e7396d13c3fee525cd663f12b6ac4877070ff4e8  pixman-0.42.2.tar.xz
78837937b59bd1b6d2a916bf73152908186fbedebf2be4fe2a89e978ac787b7827a3858970c9b69445d737545f786732394b62ac54751f5996cbedc492aefd59  scaling-test.patch
"
